import request from '../../utils/request'
import {
  getPermissionListArr
} from '../../utils/getGood'
Page({
  data: {
    // 左边边的数据
    goodType: [],
    // 点击的数据
    type_index: 0,
    // 右边
    goodArr: ""

  },
  async changeType(e) {
    let value = e.currentTarget.dataset
    this.setData({
      type_index: value.typeindex
    })
    this.getGoodType()
  },
  // 请求二级列表
  getGoodType() {
    this.setData({
      goodArr: this.data.goodType[this.data.type_index].children ? this.data.goodType[this.data.type_index].children : []
    })
  },
  tolist(e){
    console.log(e.currentTarget.dataset.keyid);
    let key_id=e.currentTarget.dataset.keyid
    if(e){
      wx.navigateTo({
        url:`/pages/list/list?key_id=${key_id}`
      })
    }
  },
  onLoad: async function () {
    let res = await request("api/goodType")
    console.log(res);
    let AllList = getPermissionListArr(res.data);
    this.setData({
      goodType: AllList
    })
    this.getGoodType()
  }
});